/**
 *城市资源列表
 */

define(["require",
		"dojo/_base/declare",
		"dojo/_base/lang",
		"dojo/_base/array",
		"dojo/_base/fx",
		"dojo/fx/easing",
		"../../util/ajaxUtil",
		"dojo/dom",
		"dojo/dom-attr",
		"dojo/dom-class",
		"dojo/dom-style",
		"dojo/on",
		"dojo/query",
		"dojo/topic",
		"../BaseWidget",
		"gistech/widgets/LandManageAndControlReportWidget/LandManageAndControlReportWidget",
		 "gistech/widgets/drawGeometryWidget/DrawGeometryWidget",
		"gistech/widgets/SpecialDataReportWidget/SpecialDataReportWidget",
		"esri/layers/FeatureLayer","esri/InfoTemplate","esri/geometry/Extent",
        "dijit/layout/ContentPane","dojo/text!./templates/Template.html"],
    function (require, declare, lang, array, baseFx,easing,ajaxUtil, dom, domAttr, domClass, domStyle, on, query, topic, 
    		BaseWidget,LandManageAndControlReportWidget,DrawGeometryWidget,SpecialDataReportWidget,
    		FeatureLayer,InfoTemplate,Extent,ContentPane, template) {
        return declare([BaseWidget], {
        	templateString: template,
            map: null,
            lefttabCon:null,
            treenode:null,
            constructor: function (args) {
                this.map = args.map;
                this.lefttabCon  = args.lefttabCon;       
            },

            postCreate: function () {
            	this.inherited(arguments);
 
            },

            startup: function () {
                this.inherited(arguments);
                this.init();
            },

 
            init:function(){
            	this.treenode = [];
            	this.ShowCityLis();
            	
            },
            location:function(args){
//            	this.distictExtent=distictObj;
            	var extent=new  Extent({"xmin":parseFloat(distictObj[args].xmin),"ymin":parseFloat(distictObj[args].ymin),
            		"xmax":parseFloat(distictObj[args].xmax),"ymax":parseFloat(distictObj[args].ymax),
            	    "spatialReference":distictObj["spatialReference"]});
            	console.log(args);
            	this.map.setExtent(extent);

            },
    		ShowCityLis:function() {     			
    			var zNodes =[
    			            {id:1,pId:0,name:"广州市",nocheck:true},
    			            {id:11, pId:1, name:"白云区",exid:"byq",nocheck:true},
    			            {id:12, pId:1, name:"从化市",exid:"chs",nocheck:true},
    			            {id:13, pId:1, name:"番禺区",exid:"fyq", nocheck:true},
    			            {id:13, pId:1, name:"海珠区",exid:"hzq",nocheck:true},
    			            {id:13, pId:1, name:"花都区",exid:"hdq",nocheck:true},
    			            {id:13, pId:1, name:"荔湾区",exid:"lwq",nocheck:true},
    			            {id:13, pId:1, name:"萝岗区",exid:"logq",nocheck:true},
    			            {id:13, pId:1, name:"南沙区",exid:"nsq",nocheck:true},
    			            {id:13, pId:1, name:"天河区",exid:"thq",nocheck:true},
    			            {id:13, pId:1, name:"越秀区",exid:"yxq",nocheck:true},
    			            {id:13, pId:1, name:"增城市",exid:"zcq",nocheck:true},
    			            
    			            {id:2,pId:0,name:"深圳市",nocheck:true},
    			            {id:21, pId:2, name:"宝安区",exid:"baq",nocheck:true},
    			            {id:22, pId:2, name:"大鹏新区",exid:"dpxq",nocheck:true},
    			            {id:23, pId:2, name:"福田区",exid:"ftq",nocheck:true},
    			            {id:24, pId:2, name:"光明新区",exid:"gmxq",nocheck:true},
    			            {id:25, pId:2, name:"龙岗区",exid:"lgq",nocheck:true},
    			            {id:26, pId:2, name:"龙华新区",exid:"lhxq",nocheck:true},
    			            {id:27, pId:2, name:"罗湖区",exid:"lhq",nocheck:true},
    			            {id:28, pId:2, name:"南山区",exid:"nshq",nocheck:true},
    			            {id:29, pId:2, name:"坪山新区",exid:"psxq",nocheck:true},
    			            {id:210, pId:2, name:"盐田区",exid:"ytq",nocheck:true},
    			            
    			            {id:3,pId:0,name:"珠海市",nocheck:true,},
    			            {id:31, pId:3, name:"斗门区",exid:"dmq", nocheck:true},
    			            {id:32, pId:3, name:"金湾区",exid:"jwq",nocheck:true},
    			            {id:33, pId:3, name:"香洲区",exid:"xzq",nocheck:true},
    			            
    			            {id:4,pId:0,name:"佛山市",nocheck:true,},
    			            {id:41, pId:4, name:"禅城区",exid:"ccq",nocheck:true},
    			            {id:42, pId:4, name:"高明区",exid:"gmq",nocheck:true},
    			            {id:43, pId:4, name:"南海区",exid:"nhq",nocheck:true},
    			            {id:44, pId:4, name:"三水区",exid:"ssq",nocheck:true},
    			            {id:45, pId:4, name:"顺德区",exid:"sdq",nocheck:true},
    			            
    			            {id:5,pId:0,name:"东莞市",nocheck:true,},
    			            {id:51, pId:5, name:"西北区",exid:"dxbq",nocheck:true},
    			            {id:52, pId:5, name:"东北区",exid:"ddbq",nocheck:true},
    			            {id:53, pId:5, name:"中心区",exid:"dzxq",nocheck:true},
    			            {id:54, pId:5, name:"西南区",exid:"dxnq",nocheck:true},
    			            {id:56, pId:5, name:"松朗区",exid:"dslq",nocheck:true},
    			            {id:57, pId:5, name:"东南区",exid:"ddnq",nocheck:true}
    			            	 			
    			 		];	
    				var ztreeSetting = { 
    					check: { 
    					  autoCheckTrigger : false,
    					  nocheckInherit : false,
    					  chkDisabledInherit : false,
    					  radioType : "level"},
    					data:{simpleData:{enable:true}},
    					callback: { onClick: lang.hitch(this,this.xxTreeNodeClick)},
    					view:{
    						showIcon:false,
    						selectedMulti: false
    					}};	
    				$.fn.zTree.init($("#citytree"), ztreeSetting, zNodes);
    				var treeObj = $.fn.zTree.getZTreeObj("citytree");
//    				treeObj.expandAll(true);//展开所有节点
    				
    		},
    		xxTreeNodeClick:function(event, treeId, treeNode){
    			if(treeNode.isParent){
//    				alert("no")
    				return;
    			}else{
    				this.location(treeNode.exid);
    			}	
    		},
            destroy: function () {
                var widgets = this.widgets;
                for (var name in widgets) {
                    if (widgets[name]) {
                        widgets[name].destroy();
                    }
                }
                this.inherited(arguments);
            },
      
        });
    });